<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        /*选中第一个li*/
        li:first-child {
            background-color: green;
            list-style: none;
        }
        /*选中最后一个*/
        li:last-child {
            background-color: red;
            list-style: none;
        }
        /*选中第五个*/
        li:nth-child(5){
            background-color: blue;
        }

        /*从后往前找*/
        li:nth-last-child(2) {
            background-color: #ff8500;
        }
    </style>
</head>
<body>
<ul>
    <li>1</li>
    <li>2</li>
    <li>3</li>
    <li>4</li>
    <li>5</li>
    <li>6</li>
    <li>7</li>
    <li>8</li>
</ul>
</body>
</html>